<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Swiper demo</title>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <!-- Link Swiper's CSS -->
    <link
      rel="stylesheet"
      href="../swiper-bundle.min.css"
    />

    <!-- Demo styles -->
    <style>
      body {
        background: #eee;
        font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
        font-size: 14px;
        color: #000;
        margin: 0;
        padding: 0;
      }

      .swiper {
        width: 100%;
        height: 300px;
        margin: 20px auto;
      }

      .swiper-slide {
        text-align: center;
        font-size: 18px;
        background: #fff;

        /* Center slide text vertically */
        display: -webkit-box;
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
        -webkit-box-pack: center;
        -ms-flex-pack: center;
        -webkit-justify-content: center;
        justify-content: center;
        -webkit-box-align: center;
        -ms-flex-align: center;
        -webkit-align-items: center;
        align-items: center;
      }

      .append-buttons {
        text-align: center;
        margin-top: 20px;
      }

      .append-buttons a {
        display: inline-block;
        border: 1px solid #007aff;
        color: #007aff;
        text-decoration: none;
        padding: 4px 10px;
        border-radius: 4px;
        margin: 0 10px;
        font-size: 13px;
      }
    </style>
  </head>

  <body>
    <!-- Swiper -->
    <div class="swiper">
      <div class="swiper-wrapper"></div>
      <!-- Add Pagination -->
      <div class="swiper-pagination"></div>
      <!-- Add Arrows -->
      <div class="swiper-button-next"></div>
      <div class="swiper-button-prev"></div>
    </div>
    <p class="append-buttons">
      <a href="#" class="prepend-2-slides">Prepend 2 Slides</a>
      <a href="#" class="slide-1">Slide 1</a>
      <a href="#" class="slide-250">Slide 250</a>
      <a href="#" class="slide-500">Slide 500</a>
      <a href="#" class="append-slide">Append Slide</a>
    </p>

    <!-- Swiper JS -->
    <script src="../swiper-bundle.min.js"></script>

    <!-- Initialize Swiper -->
    <script>
      let appendNumber = 600;
      let prependNumber = 1;
      const swiper = new Swiper('.swiper', {
        slidesPerView: 3,
        centeredSlides: true,
        spaceBetween: 30,
        pagination: {
          el: '.swiper-pagination',
          type: 'fraction',
        },
        navigation: {
          nextEl: '.swiper-button-next',
          prevEl: '.swiper-button-prev',
        },
        virtual: {
          slides: (function () {
            const slides = [];
            for (var i = 0; i < 600; i += 1) {
              slides.push('Slide ' + (i + 1));
            }
            return slides;
          })(),
        },
      });

      document
        .querySelector('.slide-1')
        .addEventListener('click', function (e) {
          e.preventDefault();
          swiper.slideTo(0, 0);
        });

      document
        .querySelector('.slide-250')
        .addEventListener('click', function (e) {
          e.preventDefault();
          swiper.slideTo(249, 0);
        });

      document
        .querySelector('.slide-500')
        .addEventListener('click', function (e) {
          e.preventDefault();
          swiper.slideTo(499, 0);
        });

      document
        .querySelector('.prepend-2-slides')
        .addEventListener('click', function (e) {
          e.preventDefault();
          swiper.virtual.prependSlide([
            'Slide ' + --prependNumber,
            'Slide ' + --prependNumber,
          ]);
        });

      document
        .querySelector('.append-slide')
        .addEventListener('click', function (e) {
          e.preventDefault();
          swiper.virtual.appendSlide('Slide ' + ++appendNumber);
        });
    </script>
  </body>
</html>
